package com.cloud.service;


import com.cloud.entity.CommonResult;
import com.cloud.entity.Payment;
import com.cloud.service.impl.GetOrderByFeignFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

/**
 * 在启动入口加入支持feign注解@EnableFeignClients
 * fallback为发生错误调用的接口实现
 */
@Component
@FeignClient(value = "cloud-payment-service-nacos",fallback = GetOrderByFeignFallback.class)
public interface GetOrderByFeign {


    /**
     * 去调用value中的微服务名称 getmapping为微服务上的controller地址
     * 返回值ribbon进行转换
     * getOrder实现的方法实际为触发了Sentinel的配置调用的方法
     * @param id
     * @return
     */
    @GetMapping(value = "/payment/select/{id}")
    public CommonResult<Payment> getOrder(@PathVariable("id") String id);
}

